<?php
require_once dirname(dirname(dirname(__FILE__))).'/HEAConfig.php';
require_once 'HorseEngine/Weather/Service/WeatherServiceFactory.php';
$weatherService = WeatherServiceFactory::getInstance()->createWeatherService();

require_once 'getoriginaldb.php';
if (is_array($first_day) && $first_day["day"]["weather"]) {
	$weathersnew = array(
		"addtime"       => time(),
		"firstday_w"    => $first_day["day"]["weather"],
		"firstday_t"    => $first_day["day"]["temperature"],
		"firstnight_w"  => $first_day["night"]["weather"],
		"firstnight_t"  => $first_day["night"]["temperature"],
		"secondday_w"   => $second_day["day"]["weather"],
		"secondday_t"   => $second_day["day"]["temperature"],
		"secondnight_w" => $second_day["night"]["weather"],
		"secondnight_t" => $second_day["night"]["temperature"],
		"thirdday_w"    => $third_day["day"]["weather"],
		"thirdday_t"    => $third_day["day"]["temperature"],
		"thirdnight_w"  => $third_day["night"]["weather"],
		"thirdnight_t"  => $third_day["night"]["temperature"],
	);	
	if ($weatherService->getWeather()) {
		$id = 1;
		$weatherService->updateYesterdayWeather($weathersnew,$id);
	} else {
		$weatherService->addTodayWeather($weathersnew);
	}
}